home *** CD-ROM | disk | FTP | other *** search
/ Apple Reference & Presen…tion Library 4 (Reseller) / Apple Ref. & Pres. Lib.v4.0.iso / 2-Graphics / Apple Graphics Source / Apple Graphics Source 2.3 / Apple Graphics Source 2.3 / stack.txt < prev   
Text File  |  1990-03-28  |  15KB  |  483 lines

  1. -- stack: in.3
  2. -- format: 8 (HyperCard 1)
  3. -- flags: 0x9000 (can't modify)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=0, y1=0, x2=0, y2=0)
  7. -- screen: Rect(x1=0, y1=0, x2=0, y2=0)
  8. -- card dimensions: w=0 h=0
  9. -- scroll: x=0 y=0
  10. -- background count: 2
  11. -- first background id: 3618
  12. -- card count: 2014
  13. -- first card id: 3356
  14. -- list block id: 2937
  15. -- print block id: 0
  16. -- font table block id: 0
  17. -- style table block id: 0
  18. -- free block count: 6
  19. -- free size: 179520 bytes
  20. -- total size: 2342912 bytes
  21. -- stack block size: 14336 bytes
  22. -- created by hypercard version: 0x01258000
  23. -- compacted by hypercard version: 0x01228000
  24. -- modified by hypercard version: 0x01228000
  25. -- opened by hypercard version: 0x01228000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x8000000008000000
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0x8888222288882222
  30. -- patterns[4]: 0x88AA22AA88AA22AA
  31. -- patterns[5]: 0xCCAA33AACCAA33AA
  32. -- patterns[6]: 0xEEAABBAAEEAABBAA
  33. -- patterns[7]: 0xEEBBBBEEEEBBBBEE
  34. -- patterns[8]: 0xFFBBFFEEFFBBFFEE
  35. -- patterns[9]: 0xFFBBFFFFFFBBFFFF
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x1122448811224488
  40. -- patterns[14]: 0xC4800C6843023026
  41. -- patterns[15]: 0xB130031BD8C00C8D
  42. -- patterns[16]: 0xAA00AA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0x0
  67. ----- HyperTalk script -----
  68. My notes
  69. --If you click the first visible line of the list, and the first
  70. --first visible line is not line 1, then the list jumps.
  71. --Assign Apple HD20 to the graphics I deleted it from.
  72. --Delete Apple from the Keyword index.
  73.  
  74. --SYSTEM MESSAGES------------------------------------------------------
  75.  
  76. on openStack
  77.   global artManagement, firstTimeAGS
  78.   if the version < 1.2 then
  79.     dialogIt "Sorry. You need HyperCard version 1.2 or greater." && "You are using version" & the version & "."
  80.   end if
  81.   if firstTimeAGS = empty then
  82.     --This is the first time you have opened the stack in this
  83.     --HyperCard session.
  84.     if the short name of this stack contains "graphics database toolkit"
  85.     then put true into artManagement
  86.   else put false into artManagement
  87. end if
  88. show menubar
  89. pass openStack
  90. end openStack
  91.  
  92. on closeStack
  93.   global artManagement
  94.   saveChanges true
  95.   if artManagement then
  96.     set cursor to busy
  97.     lock screen
  98.     set lockMessages to true
  99.     set lockRecent to true
  100.     go cd "title card"
  101.     send "adminElements false" to this bg
  102.     go bg "the collection"
  103.     send "adminElements false" to this bg
  104.   end if
  105.   pass closeStack
  106. end closeStack
  107.  
  108. on arrowKey whichKey
  109.   set textArrows to not (selectedChunk() = "")
  110.   pass arrowkey
  111. end arrowKey
  112.  
  113. on domenu menu                       --// Added by Medior, Inc. 2/20/90
  114.   global RPStackName
  115.   if menu is in "Home,Quit HyperCard" and RPStackName is not empty then
  116.     set cursor to watch
  117.     put RPStackName into shortname
  118.     repeat until offset(":",shortname) = 0
  119.       delete char 1 to offset(":",shortname) of shortname
  120.     end repeat
  121.     delete last char of shortname
  122.     answer "This will return to "&shortname&"." with "Cancel" or "OK"
  123.     if it is "Cancel" then exit domenu
  124.     set cursor to watch
  125.     lock screen
  126.     go RPStackName
  127.     unlock screen with dissolve
  128.     exit domenu
  129.   else pass doMenu
  130. end domenu
  131.  
  132.  
  133. --MESSAGE HANDLERS----------------------------------------------------
  134.  
  135. on admin
  136.   global artManagement
  137.   put true into artManagement
  138.   send "adminElements true" to this bg
  139.   if the cantModify of this stack then
  140.     dialogIt "To use the admin buttons in the background The Collection," && "move this stack to an unlocked volume."
  141.   end if
  142. end admin
  143.  
  144. on closeAdmin
  145.   global artManagement
  146.   put false into artManagement
  147.   send "adminElements false" to this bg
  148. end closeAdmin
  149.  
  150. on showListName
  151.   global activeListName
  152.   if the short name of this bg <> "the collection" then
  153.     go bg "the collection"
  154.   end if
  155.   set the name of bg btn id 353 to "List Name:" && activeListName
  156. end showListName
  157.  
  158. on goListStack thisCard
  159.   --Takes you to the list stack, or returns "no" if this is unsuccesful.
  160.   --thisCard, the name of the card in the list stack
  161.   --you want to go to. is optional.
  162.   global listStack
  163.   lock screen
  164.   set lockMessages to true
  165.   set lockRecent to true
  166.   go stack listStack
  167.   if the short name of this stack <> listStack then exit to hypercard
  168.   if cantModify of this stack then
  169.     dialogIt "The stack" && quote & listStack & quote && "is locked." && "You can't save changes to your lists until you unlock" && "the stack" && quote & listStack & quote & "."
  170.     return "no"
  171.   end if
  172.   if thisCard <> empty then go cd thisCard
  173.   if the result <> empty then
  174.     --this card wasn't found
  175.     dialogIt "The card" && thisCard && "was not found in" && "the stack" && listStack && "."
  176.     return "no"
  177.   end if
  178. end goListStack
  179.  
  180. --LIST scripts
  181.  
  182. on saveChanges dialogNeeded
  183.   --dialogNeeded = true if a dialog is needed asking the user
  184.   --if they want to save changes.
  185.   global activeListName, taggedList, changesToList
  186.   if changesToList <> true then exit saveChanges
  187.   --the exit was made because a save was unnecessary.
  188.   if dialogNeeded then
  189.     --the user needs to be asked if they want to save changes.
  190.     dialogIt "Save changes to the list " & quote & activeListName & quote &"?", "No,Yes"
  191.     if the result is "No" then exit saveChanges
  192.   end if
  193.   put the long name of this cd into afterSaveGoHere
  194.   if activeListName = "untitled" OR activeListName = empty then
  195.     --get a name for this list.
  196.     checkListName "Save the untitled list as (15 letters or less):"
  197.     if the result <> empty then exit saveChanges
  198.   end if
  199.   --you are at the new list card.
  200.   goListStack activeListName
  201.   if the result = "no" then
  202.     go afterSaveGoHere
  203.     exit to hypercard
  204.   end if
  205.   set cursor to busy
  206.   put taggedList into fld "tagged list"
  207.   go afterSaveGoHere
  208.   set cursor to busy
  209.   put false into changesToList
  210.   showListName
  211. end saveChanges
  212.  
  213. on checkListName prompt,default
  214.   --Returning a non-empty value means the list entered is invalid and
  215.   --the calling handler needs to exit.
  216.   global activeListName
  217.   if default = "untitled" then put empty into default
  218.   ask prompt with default
  219.   put it into whichName
  220.   if whichName = empty then return "1"
  221.   else if not validListName(whichName) then
  222.     checkListName prompt,default
  223.     exit checkListName
  224.   end if
  225.   --You're in the list stack.
  226.   put whichName into activeListName
  227.   go last cd of this bg
  228.   doMenu "new card"
  229.   set the name of this cd to activeListName
  230. end checkListName
  231.  
  232. on dialogIt whichText, whichButtons, whichFont, whichIcon
  233.   if whichButtons = empty then put "OK" into whichButtons
  234.   if whichIcon = empty then put "0" into whichIcon
  235.   if whichFont = empty then put "chicago" into whichFont
  236.   get dialog(whichText,whichButtons,whichIcon,whichFont,plain,12)
  237.   return it
  238. end dialogIt
  239.  
  240. --MENU scripts------------------------------------------------------
  241.  
  242. on buildMenus
  243.   buildCatalogMenu
  244.   buildIndexesMenu
  245.   buildManagementMenu
  246.   buildCardMenu
  247. end buildMenus
  248.  
  249. on buildCatalogMenu
  250.   global catalogMenu
  251.   put empty into catalogMenu
  252.   put "Catalog Volume‚Ķ" & return after catalogMenu
  253.   put "Catalog Folder‚Ķ" & return after catalogMenu
  254.   put "Catalog File‚Ķ" & return after catalogMenu
  255.   if cantModify of this stack then
  256.     repeat with i = 1 to the number of lines in catalogMenu
  257.       put "(" before line i of catalogMenu
  258.     end repeat
  259.   end if
  260. end buildCatalogMenu
  261.  
  262. on buildIndexesMenu
  263.   global indexesMenu
  264.   put empty into indexesMenu
  265.   put "Build Keyword Index" & return after indexesMenu
  266.   put "Add to Keyword Index‚Ķ" & return after indexesMenu
  267.   put "Delete from Keyword Index‚Ķ" & return after indexesMenu
  268.   put "Export Keyword Index" & return after indexesMenu
  269.   put "(-" & return after indexesMenu
  270.   put "Build Book Index" & return after indexesMenu
  271.   put "Add to Book Index‚Ķ" & return after indexesMenu
  272.   put "Delete from Book Index‚Ķ" & return after indexesMenu
  273.   put "Export Book Index" & return after indexesMenu
  274.   if cantModify of this stack = true then
  275.     repeat with i = 1 to the number of lines in indexesMenu
  276.       put "(" before line i of indexesMenu
  277.     end repeat
  278.   end if
  279. end buildIndexesMenu
  280.  
  281. on buildManagementMenu
  282.   global managementMenu
  283.   put empty into managementMenu
  284.   put "Set Browsing Speed‚Ķ" & return after managementMenu
  285.   put "Sort by File Name" & return after managementMenu
  286.   put "(-" & return after managementMenu
  287.   put "Import Data‚Ķ" & return after managementMenu
  288.   put "Delete Data" & return after managementMenu
  289.   if cantModify of this stack then
  290.     repeat with i = 1 to the number of lines in managementMenu
  291.       put "(" before line i of managementMenu
  292.     end repeat
  293.   end if
  294. end buildManagementMenu
  295.  
  296. on buildCardMenu
  297.   global cardMenu
  298.   put empty into cardMenu
  299.   put "Build Thumbnail" & return after cardMenu
  300.   put "(-" & return after cardMenu
  301.   put "Assign Keyword‚Ķ" & return after cardMenu
  302.   put "Delete Keyword‚Ķ" & return after cardMenu
  303.   put "(-" & return after cardMenu
  304.   put "Assign Book‚Ķ" & return after cardMenu
  305.   put "Delete Book‚Ķ" & return after cardMenu
  306.   if cantModify of this stack then
  307.     repeat with i = 1 to the number of lines in cardMenu
  308.       put "(" before line i of cardMenu
  309.     end repeat
  310.   end if
  311. end buildcardMenu
  312.  
  313. --FUNCTIONS----------------------------------------------------------
  314.  
  315. function listDialog thelist,delimit,text,selectMode,theButtons
  316. global DialogButton
  317. --DialogButton is the name of the button the user clicked to leave
  318. --the dialog box.
  319. get showList(theList,delimit,text,selectMode,theButtons)
  320. put it into theReply
  321. put line 1 of theReply into DialogButton
  322. if DialogButton = "cancel" then return "cancel"
  323. delete line 1 of theReply
  324. repeat with N = 1 to the number of lines in theReply
  325.   delete item 2 of line N of theReply
  326. end repeat
  327. delete last char of theReply
  328. return theReply
  329. end listDialog
  330.  
  331. function sortContainer whichContainer
  332. --returns the given container sorted alphabetically.
  333. put alphaSort(whichContainer) into it
  334. return it
  335. end sortContainer
  336.  
  337. function substitute originalChar, newChar, whichContainer
  338. --returns the given container with the given existing character
  339. --substituted in all cases for the given new character.
  340. repeat
  341.   put offset(originalChar,whichContainer) into whichChar
  342.   if whichChar = 0 then exit repeat
  343.   put newChar into char whichChar of whichContainer
  344. end repeat
  345. return whichContainer
  346. end substitute
  347.  
  348. function validListName whichName
  349. if whichName = empty then return false
  350. if whichName = "Untitled" then
  351.   answer "List can't be named Untitled."
  352.   return false
  353. end if
  354. if whichName = "id" then
  355.   answer "Lists can't be named ID."
  356.   return false
  357. end if
  358. if the length of whichName > 15 then
  359.   answer "List names cannot have more than 15 letters."
  360.   return false
  361. end if
  362. if nonNegativeNumber(whichName) then
  363.   dialogIt "List names must contain at least one letter." && "The list name" && quote & whichName & quote && "is invalid."
  364.   return false
  365. end if
  366. goListStack
  367. if the result = "no" then
  368.   pop cd
  369.   exit to hypercard
  370. end if
  371. go bg "lists"
  372. repeat with i = 1 to (the number of cds in this bg)
  373.   if the short name of this cd = whichName then
  374.     dialogIt "There is already a list named" &"e& whichName "e& ". Please use a different name."
  375.     return false
  376.   end if
  377.   go next cd of this bg
  378. end repeat
  379. return true
  380. end validListName
  381.  
  382. function positiveWholeNumber whatString
  383. --if whatString is a positive whole number, returns true.
  384. --Otherwise, returns false.
  385. if containsANumber(whatString) = false then return false
  386. repeat with i = 1 to the length of whatString
  387.   if "1234567890" contains char i of whatString then next repeat else
  388.   -- There is at least one non-number so exit now.
  389.   return false
  390. end if
  391. end repeat
  392. --the final test
  393. if whatString > 0 then return true
  394. else return false
  395. end positiveWholeNumber
  396.  
  397. function nonNegativeNumber whatString
  398. --returns true if the given string is a non-negative number.
  399. if containsANumber(whatString) = false then return false
  400. repeat with i = 1 to the length of whatString
  401.   if ".1234567890" contains char i of whatString then next repeat else
  402.   -- if it makes it here, there is an invalid character,
  403.   -- so exit now.
  404.   return false
  405. end if
  406. end repeat
  407. return true
  408. end nonNegativeNumber
  409.  
  410. function containsANumber whatString
  411. --returns true if at least one of the characters in the
  412. --string is a number. Otherwise, returns false
  413. repeat with i = 1 to the length of whatString
  414.   if "1234567890" contains char i of whatString then
  415.     --there is at least one number, so go to the next test.
  416.     exit repeat
  417.   else if i = the length of whatString then
  418.     --you've gone through all characters & there aren't any numbers.
  419.     return false
  420.   end if
  421. end repeat
  422. return true
  423. end containsANumber
  424.  
  425. function getShortName longName
  426. --given the path to a file, this function returns
  427. --the name of the file
  428. repeat
  429.   if longName contains ":" then
  430.     put offset (":",longName) into thisChar
  431.     delete char 1 to thisChar of longName
  432.   else exit repeat
  433. end repeat
  434. return longName
  435. end getShortName
  436.  
  437. function getPath longName
  438. --given the full path to a file, this function returns
  439. --the path to the file minus the name of the file
  440. repeat
  441.   if last char of longName <> ":" then delete last char of longName
  442.   else exit repeat
  443. end repeat
  444. return longName
  445. end getPath
  446.  
  447. function volumeName pathName
  448. --given the full path to a file, this function returns
  449. --the name of the volume (i.e., the disk name, or top directory)
  450. put empty into theName
  451. repeat with i = 1 to the number of chars in pathName
  452.   if char i of pathName = ":" then return theName
  453.   else put char i of pathName after theName
  454. end repeat
  455. end volumeName
  456.  
  457. =====================================================================
  458.  
  459. Changes
  460. --rewrote the way path names are sent to the Home stack
  461. --Replaced the listSelect XFCN and all calls to it
  462. with the showList XFCN.
  463.  
  464. =======================================================================
  465. COPYRIGHT NOTICES
  466. AlphaSort, ¬© Jay Hodgdon, 1989
  467. Dialog, ¬© Gary Bond, 1989
  468. BigPop, ¬© Jay Hodgdon, 1989
  469. DisPict, ¬© Apple Computer, 1988-1990
  470. FIleName, ¬© Steve Maller, 1989
  471. FolderName, ¬© Eric Carlson and Anup Murarka, 1989
  472. GetFIleName, ¬© Apple Computer, 1989-1990
  473. ListOurFiles, ¬© Apple Computer, 1988-1990
  474. ListVol, ¬© Apple Computer, 1989-1990
  475. Mount, ¬© Landon Dyer, 1989
  476. ShowList, ¬© Gary Bond, 1989
  477. TinyPict, ¬© Apple Computer, 1988-1990
  478. UnMount, ¬© Landon Dyer, 1989
  479. (The original versions of DispPict, ListOurFiles, ListVol, and TinyPict
  480. were written by David Fry.)
  481. =======================================================================
  482.  
  483.